var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("RoleSoldierInfo"),
    l = e("UIManager"),
    c = e("GetZsViewUI"),
    d = e("Toast"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.dower_icon_imager = null),
                (t.dower_icon_num = null),
                (t.dower_name_label = null),
                (t.dis_count_num_label = null),
                (t.coin_node = null),
                (t.buy_coin_num = null),
                (t.zs_node = null),
                (t.buy_zs_num = null),
                (t.dis_count_node = null),
                (t.buy_btn_node = null),
                (t.mask_node = null),
                (t.buy_over_mask = null),
                (t.dower_info = null),
                (t.dower_index = 0),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.showDowerInfo = function (e, t) {
                (this.dower_info = e),
                    (this.dower_index = t),
                    (this.dower_icon_imager.spriteFrame = i.default
                        .getInstance()
                        .getDowerImagerFrame("dower_" + this.dower_info.dower + "_0")),
                    (this.dower_icon_num.string = "x" + this.dower_info.num),
                    (this.dower_name_label.string = s.default.Dower_info[this.dower_info.dower].spirit_name + "碎片"),
                    (this.dis_count_num_label.string = 10 * this.dower_info.discount + "折"),
                    (this.dis_count_num_label.node.parent.active = 1 != this.dower_info.discount),
                    (this.coin_node.active = 0 == this.dower_info.type),
                    (this.zs_node.active = 1 == this.dower_info.type),
                    (this.buy_coin_num.string = "" + 100 * this.dower_info.num * this.dower_info.discount),
                    (this.buy_zs_num.string = "" + 20 * this.dower_info.num * this.dower_info.discount),
                    (this.dis_count_node.active = 1 != this.dower_info.discount),
                    (this.dis_count_node.getComponent(cc.Label).string =
                        "" + this.dower_info.num * (0 == this.dower_info.type ? 100 : 20)),
                    (this.buy_over_mask.active = this.dower_info.is_buy),
                    (this.mask_node.active = a.GlobalParams.PlayerInfo.value.level < 9 && t > 5),
                    this.buy_btn_node.on("click", this.buyDowerInfo, this);
            }),
            (t.prototype.buyDowerInfo = function () {
                var e = this;
                r.default.ButtonSound();
                var t = function () {
                        var t = a.GlobalParams.PlayerDowerInfo.value;
                        (t.debris[e.dower_info.dower] += e.dower_info.num), (a.GlobalParams.PlayerDowerInfo.value = t);
                        var o = a.GlobalParams.ShopDowerInfo.value;
                        (o.info[e.dower_index].is_buy = !0),
                            (a.GlobalParams.ShopDowerInfo.value = o),
                            (e.buy_over_mask.active = !0);
                    },
                    o = a.GlobalParams.PlayerInfo.value;
                if (0 == this.dower_info.type) {
                    var n = 100 * this.dower_info.num * this.dower_info.discount;
                    o.coin >= n
                        ? (cc.find("UIManager").getComponent(l.default).consumeCoinAndZs(0, n), t())
                        : d.default.showNewToast("金币不足");
                } else if (1 == this.dower_info.type) {
                    var i = 20 * this.dower_info.num * this.dower_info.discount;
                    o.zs >= i
                        ? (cc.find("UIManager").getComponent(l.default).consumeCoinAndZs(1, i), t())
                        : cc
                              .find("UIManager")
                              .getComponent(l.default)
                              .showPopup("GetZsViewUI", function (e) {
                                  e.getComponent(c.default).showPopupInfoView(0);
                              });
                }
            }),
            __decorate([u(cc.Sprite)], t.prototype, "dower_icon_imager", void 0),
            __decorate([u(cc.Label)], t.prototype, "dower_icon_num", void 0),
            __decorate([u(cc.Label)], t.prototype, "dower_name_label", void 0),
            __decorate([u(cc.Label)], t.prototype, "dis_count_num_label", void 0),
            __decorate([u(cc.Node)], t.prototype, "coin_node", void 0),
            __decorate([u(cc.Label)], t.prototype, "buy_coin_num", void 0),
            __decorate([u(cc.Node)], t.prototype, "zs_node", void 0),
            __decorate([u(cc.Label)], t.prototype, "buy_zs_num", void 0),
            __decorate([u(cc.Node)], t.prototype, "dis_count_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "buy_btn_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "mask_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "buy_over_mask", void 0),
            __decorate([_], t)
        );
    })(n.default);
o.default = p;
